import 'dart:convert';

class PlayListEntity {
  final int id; // 唯一的播放列表ID
  String name; // 播放列表名称
  List<String>? videoIds; // 存储视频的ID

  PlayListEntity({
    required this.id,
    required this.name,
    this.videoIds,
  });

  // 转换为JSON字符串
  String toJsonString() {
    return jsonEncode({
      'id': id,
      'name': name,
      'videoIds': videoIds?.toList(),
    });
  }

  // 从JSON字符串转换
  factory PlayListEntity.fromJsonString(String jsonString) {
    final Map<String, dynamic> json = jsonDecode(jsonString);
    return PlayListEntity(
      id: json['id'],
      name: json['name'],
      videoIds: List<String>.from(json['videoIds']),
    );
  }
}
